#include "lh_radio.h"



void LH_RadioEve(void *widget)
{
    LH_WIDGET *DilgFoc = widget;
    
    if (DilgFoc->WidFlags & LH_WIDREDR)         
    {
        if (DilgFoc->WidFlags & LH_WIDBUD)      
        {
            if(DilgFoc->WidFlags & LH_BUDREDR)  
            {
                if(*DilgFoc->Path1 != LH_NULL)
                    LH_ShowBmpAt(DilgFoc->Axis_X, DilgFoc->Axis_Y, DilgFoc->Path1);
            }
            else
            {
                if(*DilgFoc->Path2 != LH_NULL)
                    LH_ShowBmpAt(DilgFoc->Axis_X, DilgFoc->Axis_Y, DilgFoc->Path2);
            }
        }
        else
        {
            if (TcEve.NowEvent == TOUCH_STOP)   
                *(LH_S8 *)(DilgFoc->PData) = !(*(LH_S8 *)DilgFoc->PData);
            
            if (*(LH_S8 *)DilgFoc->PData == RADIO_YES)
            {
                if(*DilgFoc->Path1 != LH_NULL)
                    LH_ShowBmpAt(DilgFoc->Axis_X, DilgFoc->Axis_Y, DilgFoc->Path1);
            }
            else
            {
                if(*DilgFoc->Path2 != LH_NULL)
                    LH_ShowBmpAt(DilgFoc->Axis_X, DilgFoc->Axis_Y, DilgFoc->Path2);
            }
        }
    }
}

void FourBoundRadio(LH_WIDGET *Dialog, LH_U8 WidSeq1, LH_U8 WidSeq2, LH_U8 WidSeq3, LH_U8 WidSeq4)
{
    LH_WIDGET *widget;
    
    widget = GetDialogWid(Dialog, WidSeq1);
    widget->WidFlags |= LH_BUDREDR;
    SetWidgetRedraw(widget);
    
    widget = GetDialogWid(Dialog, WidSeq2);
    widget->WidFlags &= ~LH_BUDREDR;
    SetWidgetRedraw(widget);  
    
    widget = GetDialogWid(Dialog, WidSeq3);
    widget->WidFlags &= ~LH_BUDREDR;
    SetWidgetRedraw(widget);   
    
    widget = GetDialogWid(Dialog, WidSeq4);
    widget->WidFlags &= ~LH_BUDREDR;
    SetWidgetRedraw(widget);   
}


void TowBoundRadio(LH_WIDGET *Dialog, LH_U8 WidSeq1, LH_U8 WidSeq2)
{
    LH_WIDGET *widget;
    
    widget = GetDialogWid(Dialog, WidSeq1);
    widget->WidFlags |= LH_BUDREDR;
    SetWidgetRedraw(widget);
    
    widget = GetDialogWid(Dialog, WidSeq2);
    widget->WidFlags &= ~LH_BUDREDR;
    SetWidgetRedraw(widget);  
}


LH_U16 CheckRdiBudReDr(LH_WIDGET *Dialog, LH_U8 WidSeq)
{
    Dialog = GetDialogWid(Dialog, WidSeq);
    if(Dialog->WidFlags & LH_BUDREDR)
        return 1;
    else
        return 0;
}



